<?php
/*
$JA#COPYRIGHT$
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

class modJAListJobsHelper{
	function get_list_jobs( $model, $limit=20, $mode='' ){
		global $jbconfig, $mainframe;				
		
		$limitstart = 0;
		
		$where_more = ' and a.status=\'Approved\' ';
		$where_more .= ' and(a.effected_date<=now()) and ( (DATE_ADD(a.effected_date, INTERVAL '. (int)$jbconfig['posts']->get('posts_display_days', 30). ' DAY) >= now()  AND a.is_hotjob=0) or (DATE_ADD(a.effected_date, INTERVAL '. (int)$jbconfig['posts']->get('posts_show_days_elapsed', 30). ' DAY) >= now()  AND a.is_hotjob=1) )';					
		if (JRequest::getVar('task')!='employer')
		{
			$filter_order = JRequest::getVar('filter_order');
			$filter_order_Dir = JRequest::getVar('filter_order_Dir');
			if ($filter_order!=null)
			{
				$mode = '';
				$mode .= $filter_order .' '. $filter_order_Dir;
			}
		}
		$all_items = $model->getItems($where_more, $limit, $limitstart, $mode);  		
		
		return $all_items;
	}
	
	function getFile($name, $modPath, $tmplPath) {
		if (file_exists(JPATH_SITE.DS.$tmplPath.$name)) {
			return $tmplPath.$name;
		}
		return $modPath.$name;
	}
	
	function _findItem()
	{		
		$Itemid = get_Itemid(array('option'=>'com_jajobboard', 'view'=>'jajobs', 'layout'=>'jalist'));
		if(!$Itemid || $Itemid == 9999) $Itemid = JRequest::getInt('Itemid');        
        return $Itemid;
	}
}